package xmlpreprocessed;

import java.io.File;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;


public class XMLParser {
	EntailmentCorpus entailmentCorpus = new EntailmentCorpus();
	
	public EntailmentCorpus getEntailementCorpus(String sourceXML){
        Serializer serializer = new Persister();
		File source = new File(sourceXML);
		try {
			 entailmentCorpus = serializer.read(EntailmentCorpus.class, source);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return entailmentCorpus;
    }

	public static void main(String[] args) {
		EntailmentCorpus example = null;
		Serializer serializer = new Persister();
		File source = new File("rte2_dev_data/RTE2_dev.preprocessed.xml");
		try {
			 example = serializer.read(EntailmentCorpus.class, source);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (Pair pair : example.getProperties()) {
			System.out.println("<pair>");
			
			System.out.println("setninger i pair: ");
			for (Sentence sentence : pair.getText().getProperties()) {
				for (Node node : sentence.getProperties()) {
					if (node.getWord() == null) continue;
					System.out.print(node.getWord().trim() + " ");
					

				}
				
			}
			//System.out.print("<id>" +pair.getId() + "</id> ");
			//System.out.print("<entailment>" +pair.getEntailment() + "</entailment> ");
			//System.out.print("<task>" +pair.getTask() + "</task> ");
			System.out.println();
			//System.out.println("<t>" + pair.getT() + "</t>");
			//System.out.println("<h>" + pair.getH() + "</h>");
			System.out.println("</pair>");

		}
	}
}
